<template>
  <div class="app-container">
    <van-nav-bar title="重置应用密码"  left-arrow @click-left="$router.back()" />
    <br />
    <h3>当前应用密码</h3>
    <div>
      <p>{{ appsec ? appsec : '请点击重置进行申请' }}</p>
    </div>
    <div  class="space-top-huge">
        <van-button  block type="primary" :loading="loading"  @click="onReset">重置应用密码</van-button>
      </div>
  </div>
</template>

<script>
import { getMyInfo, resetAppsecret } from '@/api/home'
import { showConfirmDialog } from 'vant'

export default {
  name: 'ResetAppsecret',
  data() {
    return {
      appsec: ''
    }
  },
  created() {
    getMyInfo().then(response => {
      this.appsec = response.data.appSecret
    })
  },
  methods: {
    onReset() {
      showConfirmDialog({
        title: '提示',
        message: '确定重置应用密码？',
        cancelButtonText: '取消',
        confirmButtonText: '确定'
      })
      .then(() => {
        resetAppsecret().then(response => {
          this.appsec = response.data
        })
      })
      .catch(() => { 
        
      });
      
    }
  },
}
</script>
